#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <math.h>
#include <algorithm>
#include <string>
#include <stack>
using namespace std;
int N;
vector<string>result;
void dfs(int l,int r,string has){
    if(r==N){
        result.push_back(has);
    }
    if(l<N) dfs(l+1,r,has+"(");
    if(l>r) dfs(l,r+1,has+")");
}

vector<string> generateParenthesis(int n) {
    N=n;
    dfs(0,0,"");
    return result;
}

int main(){
    vector<string>result=generateParenthesis(3);
    for(auto temp:result){
        cout<<temp<<endl;
    }
    return 0;
}